﻿
using QFramework;
using UnityEngine;

namespace ProjectChildhood
{
    public class ToolWaterScan : ITool
    {
        public string Name => "花洒";

        public int Range => Global.WaterScanUpgradeUnlock ? 2 : 1;

        public bool Selectable(ToolData toolData)
        {
            return toolData.ShowGrid[toolData.CellPos.x, toolData.CellPos.y] != null &&
                   !toolData.ShowGrid[toolData.CellPos.x, toolData.CellPos.y].HasWater;
        }

        public void Use(ToolData toolData)
        {
            // 浇水Logic
            ResController.Instance.WaterPrefab
                .Instantiate()
                .Position(toolData.GridCenterPos);

            toolData.ShowGrid[toolData.CellPos.x, toolData.CellPos.y].HasWater = true;

            ToolController toolController = Object.FindObjectOfType<ToolController>();
            Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            toolController.Fx_Watering.Position(mousePos.x, mousePos.y);
            toolController.Fx_Watering.GetComponent<ParticleSystem>().Play(); // 挖掘的粒子特效
            //音效
            AudioController.Instance.SFX_WateringScan.Play();
            CameraController.Shake(CameraController.EShakeType.Slight);
        }
    }
}
